// Name: Analogus_Interface_Fonts
// Initial version: 2012.04.14
// Author: Anlaogus
// Description: changes fonts of the reader interface

// 2012.04.25: change path for tmp-file
// 2012.04.27: shorten code
// 2012.04.28: add 3rd interface-font 
// 2012-06-10: Mark Nord - UTF-8 encoding, var-defs, now working in BETA-folder

tmp = function() 
{ 	
	//shortcuts:
	NAME = "Analogus_Interface_Fonts";
	LA = Core.lang.getLocalizer("Analogus_SYS_Fonts");
	log = Core.log.getLogger(NAME);
	MSG = Core.ui.showMsg;
	model = kbook.model;
	exec = Core.shell.exec;

	
	
	//System-Fonts (LRF, TXT, RTF):
	InterfaceFontFunction = function (font) 
		{
			exec('cat /Data/database/system/PRSPlus/prsp.sh | sed /tt0003m_.ttf/d > /Data/CSS/temp.sh; cat /Data/CSS/temp.sh > /Data/database/system/PRSPlus/prsp.sh'); 
			exec('echo "mount --bind /opt0/tt0003m_.ttf /opt/sony/ebook/FONT/tt0003m_.ttf " >> /Data/database/system/PRSPlus/prsp.sh');

			switch (font) 
				{
					case 'Font1':
						exec('cp -f /Data/fonts/InterFont1/tt0003m_.ttf /opt0');
						break ;
					case 'Font2':
						exec('cp -f /Data/fonts/InterFont2/tt0003m_.ttf /opt0');
						break; 					
					case 'Font3':
						exec('cp -f /Data/fonts/InterFont3/tt0003m_.ttf /opt0');
						break; 
					case 'FontSony': 
						exec('cat /Data/database/system/PRSPlus/prsp.sh | sed /tt0003m_.ttf/d > /Data/CSS/temp.sh; cat /Data/CSS/temp.sh > /Data/database/system/PRSPlus/prsp.sh'); 
						break ;
				}
				
			AutoRestart();

		}
//--------------------------------------------------------------------------------------------------------
	Analogus_Interface_Fonts = 
	{
		name: NAME,
		settingsGroup:"additional", 
		onInit: function () 
			{

			},
		optionDefs: 			
			[
				{
					name: 'InterfaceFont',	
					title: LA('TITLE'),
					icon: 'FONT',
					helpText: LA('HELP_SYSTEM_FONTS'),
					defaultValue: 'FontSony',
					values: ['Font1', 'Font2', 'Font3', 'FontSony'],
					valueTitles: 
						{
						'Font1': LA('SYSTEM_FONT_1'),
						'Font2': LA('SYSTEM_FONT_2'),
						'Font3': LA('SYSTEM_FONT_3'),
						'FontSony': LA('SYSTEM_FONT_SONY')
						}
				},
			], 

//----------------------------------------------------------------------------------------------------------
		
		onSettingsChanged: function (propertyName, oldValue, newValue, object) 
		{
			switch (propertyName) 
			{
				case 'InterfaceFont':
						InterfaceFontFunction (newValue);
				break; 
			}
		}
	};
	
	Core.addAddon(Analogus_Interface_Fonts);
};


try 
{
	tmp();
} catch (e) 
{
	// Core's log
	log.error("in Analogus_Interface_Fonts.js", e);
}